package com.zzti.serviceImpl;

import com.zzti.mapper.WaiterMapper;
import com.zzti.pojo.Waiter;
import com.zzti.service.WaiterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service
public class WaiterServiceImpl implements WaiterService {
    @Autowired
    private WaiterMapper waiterMapper;
    public static Integer count;

    @Override
    public Waiter findOne(Integer id) {
        return waiterMapper.selectById(id);
    }

    @Override
    public List<Waiter> findAll(Map map) {
        List<Waiter> ls1 = waiterMapper.selectList(map);
        map.remove("page");
        map.remove("limit");
        List<Waiter> ls2 = waiterMapper.selectList(map);
        count = ls2.size();
        System.out.println(ls1.toString());
        return ls1;
    }

    @Override
    public List<Waiter> findAll2(Map map) {
        return waiterMapper.selectList(map);
    }

    @Override
    public Waiter selectByName(String name) {
        return null;
    }

    @Override
    public Integer update(Waiter waiter) {
        return waiterMapper.updateById(waiter);
    }

    @Override
    public Waiter findOneWaiter(Integer id) {
        return waiterMapper.selectById(id);
    }

    @Override
    public Waiter queryByAcc(String loginUsername, String loginPassword) {
        return waiterMapper.queryByAcc(loginUsername, loginPassword);
    }

    @Override
    public Waiter queryManager(String loginUsername, String loginPassword) {
        return waiterMapper.queryManager(loginUsername, loginPassword);
    }


    @Override
    public Integer deleteByIds(Integer[] ids) {
        List<Integer> lids = Arrays.asList(ids);
        return waiterMapper.deleteBatchIds(lids);
    }

    @Override
    public Integer add(Waiter waiter) {
        return waiterMapper.insert(waiter);
    }


}
